import { http } from "./request/index"
import { QueryOptions, BodyOptions } from "./global"

export default {
<% 
function renderObject(obj, indentLevel = 1) {
  let result = '';
  const indent = ' '.repeat(indentLevel * 4); // 根据层级计算缩进
  for (let key in obj) {
    // 将 key 转换为小驼峰格式
    const camelKey = key.replace(/_([a-z])/g, (match, p1) => p1.toUpperCase());
    let typeInterface = "BodyOptions"
    if(obj[key].method&&["get","delete"].includes(obj[key].method.toLowerCase())){
      typeInterface = "QueryOptions"
    }
    if (obj[key].method && obj[key].path) {
      result += `${indent}/** ${obj[key].tags} ${obj[key].description} */\n`;
      result += `${indent}${camelKey}:(data?:${typeInterface})=> http.${obj[key].method.toLowerCase()}("${obj[key].path}",data),\n`;
    } else {
      result += `${indent}${camelKey}: {\n`;
      result += renderObject(obj[key], indentLevel + 1); // 递归调用时增加缩进级别
      result += `${indent}},\n`;
    }
  }
  return result;
} 
%>
<%- renderObject(functions) %>
}